﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using egypt.Logic.Data;

namespace egypt.Web.Admin
{
    public partial class changePassWord : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //this.ChangePassword1.MembershipProvider = "egypt.Web.egyptMembershipProvider";
        }

        protected void ChangePassword1_ChangingPassword(object sender, LoginCancelEventArgs e)
        {
            
            if (User.Identity.Name == this.ChangePassword1.UserName)
            {
                return;
            }

            DataAdapter da = new DataAdapter(System.Configuration.ConfigurationManager.ConnectionStrings["egypt"].ConnectionString);
            if (da.ChangeUserName(User.Identity.Name, this.ChangePassword1.CurrentPassword, this.ChangePassword1.UserName))
            {
                FormsAuthentication.RedirectFromLoginPage(this.ChangePassword1.UserName, true);
                e.Cancel = false;
            }
            else
            {
                e.Cancel = true;
                this.ChangePassword1.ChangePasswordFailureText = "原始密码错误！";
            }
        }
    }
}
